﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Runtime.Serialization;

namespace KPIS.GERP.Models.HRM
{
    [Table("salary_promote"), DataContract]
    public class SalaryPromote
    {
        [DataMember, Column("sp_seq"), Key, DatabaseGenerated(DatabaseGeneratedOption.Identity)]
        public int SpId { get; set; }
        
        [DataMember, Column("sp_cmd_title")]
        public string Title { get; set; }
        
        [DataMember, Column("effected_date")]
        public DateTime? EffectedDate { get; set; } 
        
        [DataMember, Column("remarks")] 
        public string Remarks { get; set; }
        
        [DataMember, Column("record_status")]
        public string RecordStatus { get; set; }
        
        [DataMember, Column("created_by")]
        public int? CreatedBy { get; set; }
        
        [DataMember, Column("created_when")]
        public DateTime? CreatedWhen { get; set; }
        
        [DataMember, Column("updated_by")]
        public int? UpdatedBy { get; set; }
        
        [DataMember, Column("updated_when")]
        public DateTime? UpdatedWhen { get; set; }
        
        [NotMapped]
        public string RemarksWord
        {
            get { return Remarks.Substring(0, Remarks.Length < 100 ? Remarks.Length : 100); }
        }
        
        [NotMapped]
        public string EffectedDateWord
        {
            get { return EffectedDate.HasValue ? EffectedDate.Value.ToString("d MMMM yyyy") : ""; }
        }

        [NotMapped]
        public string StatusWord
        {
            get {
                switch (RecordStatus)
                {
                    case "W":
                        return "ยังไม่ส่งขออนุมัติ";
                    case "P":
                        return "รอการพิจารณา";
                    case "A":
                        return "ได้รับการอนุมัติ";
                    case "C":
                        return "ถูกยกเลิก";
                    case "U":
                        return "มีผลบังคับใช้";
                    default:
                        return "?";
                }
            }
        }
        
    }
}
